#include "stdafx.h"
#include "ISCPacketCreator.h"

#include "stdafx.h"
#include "ISCPacketCreator.h"

CByteArray CISCPacketCreator::m_packet = CByteArray();

CByteArray &CISCPacketCreator::getPacket()
{
	return m_packet;
}

void CISCPacketCreator::cleanup()
{
	m_packet.destroy();
}

void CISCPacketCreator::_start(int cmd)
{
	m_packet.clear();

	m_packet.addByte(0x6b);
	m_packet.addInt(0); // taille du packet
	m_packet.addInt(cmd);
}

void CISCPacketCreator::_finish()
{
	m_packet.setInt(1, m_packet.size() - 5);
}

const CByteArray &CISCPacketCreator::authAnswer(uint id, E_AUTH_ANSWER answer)
{
	_start(ECMD_AUTHANSWER);

	m_packet.addUInt(id);
	m_packet.addByte(answer);

	_finish();

	return m_packet;
}